#include "bullet.h"
#include <QPixmap>
#include <GameSetting.h>
#include <QGraphicsScene>

Bullet::Bullet(QGraphicsItem *parent):QGraphicsPixmapItem(parent)
{
    setPixmap(QPixmap(":/images/Sprites/bullet/fly/bullet1.png"));
    setScale(GameSetting::BulltScale); //设置子弹比例
    startTimer(GameSetting::BulltTimer);
}


void Bullet::timerEvent(QTimerEvent *event)
{
    Q_UNUSED(event);
    setPos(x(),y()-GameSetting::BulletSpeed);
    if(y()+boundingRect().height()<0){ //析构掉玩家越界子弹
        scene()->removeItem(this);
        delete this;
    }
}
